<?php
namespace app\api\controller\v1;
class Goodscat extends Base
{
    //列表
    public function lists(){
        if(is_post()){
            $d = request()->post();
            $map = [];
            if($d['parent_id']!=''){
                $map[] = ['parent_id','=',$d['parent_id']];
            }
            if($d['keyword']!=''){
                $map[] = ['cat_title','like',"%{$d['keyword']}%"];
            }
        	$rs = model('GoodsCat')::where($map)
                                ->order('sort desc,id desc')
                                ->paginate($d['limit'],false,['page'=>$d['page']]);
            if($rs){
                $rs = $rs->toArray();
                return suc($rs['data'], $rs['total']);
            }else{
                return suc([],0);
            }
        }
    }
}
